package com.zcaxer.way

import android.widget.NumberPicker
import androidx.appcompat.app.AppCompatActivity
import com.zcaxer.way.data.Building
import com.zcaxer.way.fragments.InputDialogFragment
import com.zcaxer.way.viewmodels.BuildingViewModel

class Listeners(val context: AppCompatActivity) {
    fun onViewClicked(viewmodel: BuildingViewModel, building: Building, tag: String) {
        val dialogFragment = InputDialogFragment(viewmodel, building, tag)
        dialogFragment.show(context.supportFragmentManager, tag)
    }

    fun numberPickerListener(viewmodel: BuildingViewModel, building: Building): NumberPickerListener{
        return NumberPickerListener(viewmodel, building)
    }

    class NumberPickerListener(val viewmodel: BuildingViewModel, val building: Building)
        : NumberPicker.OnValueChangeListener {
        override fun onValueChange(picker: NumberPicker?, oldVal: Int, newVal: Int) {
            viewmodel.setBuildingWorkers(building, newVal)
        }
    }
}